package com.example.demo.web.manage.controller.app;

import com.example.demo.web.manage.dto.DeptDto;
import com.example.demo.web.manage.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.ModelAndView;

/**
 * @author airhead
 */
@Component(tag = "appApi")
@Api("App 端部门服务")
public class AppDeptController {
  @Inject private DeptService service;

  @Mapping(value = "listWithException")
  @Get
  @ApiOperation("获取列表但返回异常")
  public List<DeptDto> listWithException() {
    return service.listWithException();
  }

  @Mapping(value = "list")
  @ApiOperation("获取列表")
  public List<DeptDto> list() {
    return service.list();
  }

  @Mapping("/index")
  @Get
  @ApiOperation("浏览部门")
  public ModelAndView index() {
    ModelAndView mv = new ModelAndView();
    mv.put("depts", service.list());
    mv.view("dept.shtm");

    return mv;
  }
}
